/*
 * Copyright (C) 2008 Jens Meiß
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.googlecode.hmvc4gwt.example.hmvcblog.server.repository.user;

import com.googlecode.hmvc4gwt.example.hmvcblog.server.domain.user.User;
import com.googlecode.hmvc4gwt.example.hmvcblog.server.repository.IRepository;
import com.googlecode.hmvc4gwt.example.hmvcblog.server.repository.user.exceptions.UserExistException;
import com.googlecode.hmvc4gwt.example.hmvcblog.server.repository.user.exceptions.UserNotFoundException;
import com.googlecode.hmvc4gwt.example.hmvcblog.server.repository.user.exceptions.UserSessionNotFoundException;


/**
 * DAO for accessing User data
 *
 * @author jens.meiss
 */
public interface IUserRepository  extends IRepository {
	
	/**
	 * Load the user with the argument ID
	 * @param id
	 * @return the user to load
	 * @throws UserNotFoundException
	 */
	public User findById(Integer id) throws UserNotFoundException;
	
	/**
	 * Loads the user with the login
	 * @param login
	 * @return the user to load
	 * @throws UserNotFoundException
	 */
	public User findByLogin(String login) throws UserNotFoundException;
    
	/**
	 * Save or creates an user
	 * @param user
	 * @throws UserExistException
	 */
	public void storeUser(User user) throws UserExistException;
	
	/**
	 * Removes the user
	 * @param user
	 * @throws UserNotFoundException
	 */
	public void removeUser(User user) throws UserNotFoundException;
	
	/**
	 * searches the user by the given sessionId
	 * @param sessionId
	 * @return
	 * @throws UserSessionNotFoundException
	 */
	public User findBySessionId(Long sessionId) throws UserSessionNotFoundException;
	
	/**
	 * updates the user in the database
	 * @param user
	 */
	public void updateUser(User user);

}
